<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" lang="zh">
<head lang="en">
    <th:block th:include="include :: header('添加角色')"/>
</head>
<body>
<form class="layui-form" style="padding: 10px" lay-filter="form">

    <div class="layui-form-item">
        <label class="layui-form-label">类型</label>
        <div class="layui-input-block">
            <input type="checkbox" name="model" title="model和par" checked lay-text="开启|关闭" value="1">
            <input type="checkbox" name="dao" title="dao层" checked lay-text="开启|关闭" value="1">
            <input type="checkbox" name="service" title="service层" checked lay-text="开启|关闭" value="1">
            <input type="checkbox" name="controller" title="controller层" checked lay-text="开启|关闭" value="1">
            <input type="checkbox" name="html" title="html层" checked lay-text="开启|关闭" value="1">
            <input type="checkbox" name="sql" title="生成sql" checked lay-text="开启|关闭" value="1">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">html路径</label>
        <div class="layui-input-block">
            <input type="text" id="htmlFold" name="htmlFold" required  lay-verify="required"
                   class="layui-input" placeholder="请输入html路径">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">controller名称</label>
        <div class="layui-input-block">
            <input type="text" id="controllerName" name="controllerName" required  lay-verify="required"
                   class="layui-input" placeholder="HtController" value="HtController">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">controller前缀</label>
        <div class="layui-input-block">
            <input type="text" id="controllerPre" name="controllerPre" required  lay-verify="required"
                   class="layui-input" placeholder="请输入前缀" value="ht">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">父id</label>
        <div class="layui-input-block">
            <select name="parentId" lay-verify="required" id="parentId">

            </select>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">菜单名称</label>
        <div class="layui-input-block">
            <input type="text" name="menuName" required  lay-verify="required"
                   class="layui-input" placeholder="请输入菜单名称">
        </div>
    </div>
    <div style="display: none">
        <button class="layui-btn" lay-submit lay-filter="*" id="submit">立即提交</button>
    </div>
</form>
</body>
<th:block th:include="include :: footer"/>
<script type="text/javascript">

    //从父层获取值，json是父层的全局js变量。eval是将该string类型的json串变为标准的json串
    layui.use(['form'], function () {
        var form = layui.form;      
        var html="";
        config.commGet("/sysUser/getTopMenuList.json",function (data) {
            for (var i=0;i<data.length;i++){
                var dta=data[i];
                html+="<option value='"+dta.id+"'>"+dta.resuorceName+"</option>";
            }
            $("#parentId").html(html);
            form.render();
        })

                                                                    // 刷性select，显示出数据
        form.on('submit(*)', function (data) {
            data.field.desc=config.getQueryString("tableComment");
            data.field.dbName=encodeURI(config.getQueryString("tableName"));
            console.log(data.field);
            config.commPost("/auto/autoCode.json", data.field, function (data, info) {
                parent.config.tableRefresh();
                parent.config.closeLayer(info);
            })
            return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
        });
    })

    function ApplicationSave() {
        document.getElementById("submit").click();
    }
</script>
</html>

